package test;

public class quick {

    public int[] sortArray(int[] nums) {
        quickSort(nums, 0, nums.length - 1);
        return nums;
    }
    public void quickSort(int[] nums, int left, int right){
        if(left >= right)
            return;
        int flag = nums[left];
        int i = left, j = right;
        while(i < j){
            while(i < j && nums[j] >= flag)
                j--;
            while(i < j && nums[i] <= flag)
                i++;
            if(i < j){
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;
            }
        }
        nums[left] = nums[i];
        nums[i] = flag;
        quickSort(nums, left, i - 1);
        quickSort(nums, i + 1, right);
        return;
    }
}
